//Casa@131012a
#include"global.h"
extern size_t _size;

struct INDEX
{
	int32_t order;
	uint8_t *pos;
	//
	INDEX *parent;
	bool choose;
	INDEX()
	{
		pos=new uint8_t[_size];
	}
	~INDEX()
	{
		delete[] pos;
	}
	void operator=(const INDEX &rhs)
	{
		order=rhs.order;
		memcpy(pos,rhs.pos,_size);
	}
};

struct _hash
{
	size_t operator()(const INDEX *key)const
	{
		uint32_t x=key->order;
		size_t j=0;
		auto &p=key->pos;
		for(size_t i=0;i<_size;i++)
		{
			x^=uint32_t(p[i])<<j;
			j=(j+8)&0x1f;
		}
	}
};

struct _equal
{
	bool operator()(const INDEX *lhs,const INDEX *rhs)const
	{
		if(lhs->order!=rhs->order)
			return false;
		return !memcmp(lhs->pos,rhs->pos,_size);
	}
}; 

typedef unordered_map<INDEX*,uint32_t,_hash, _equal> multi_array;

